package com.ak.jddemo.test;

import com.sun.webkit.network.CookieManager;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author: lianghuan
 * @date: 2021/1/8 20:59
 */
@Data
public class Config {
    public final static String headerAgent = "User-Agent";
    public final static String headerAgentArgWin = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36";
    public final static String headerAgentArgPhone = "Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BLA-AL00 Build/HUAWEIBLA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/8.9 Mobile Safari/537.36";
    public final static String Referer = "Referer";
    public final static String RefererArg = "https://passport.jd.com/new/login.aspx";
    public static Integer status = 0;
    public static Integer carStatus = 0;
    public static ReentrantLock lock = new ReentrantLock();
    public static List<String> ipPool = new ArrayList<>();
    public static CookieManager manager = new CookieManager();
    public static String model = "win";
    public static long time;
    public static String mac;
    public static boolean seckillMode = true;
    public static List<String> logs;

    public static String pid;
    public static String eid;
    public static String fp;
    public static String enabledProxy;
    public static String proxyHost;
    public static Integer proxyPort;
    public static String enabledMultithreading;


    public static void lock(){
        if (!"true".equals(enabledMultithreading)){
            lock.lock();
        }
    }

    public static void unlock(){
        if (!"true".equals(enabledMultithreading)){
            lock.unlock();
        }
    }

    public static String getHeaderAgentArgPhone() {
        if ("win".equals(model)){
            return headerAgentArgWin;
        }else {
            return headerAgentArgPhone;
        }
    }
}
